package org.leetcode.middle.leetcode300;

import java.util.Arrays;

public class Solution2 {

    public static void main(String[] args) {
        int [] test = {10,9,2,5,3,7,101,18};

        int i = lengthOfLIS(test);
        System.out.println(i);

    }
    public static int lengthOfLIS(int[] nums) {
        int n = nums.length;

        int [] dp = new int[n];
        dp[0]=1;
        Arrays.fill(dp,1);

        int maxLength = 1;

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i]>nums[j]){
                    dp[i]=Math.max(dp[i],dp[j]+1);
                }
            }
            maxLength=Math.max(maxLength,dp[i]);
        }

        return maxLength;
    }
}
